package com.haredot.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Teacher implements User{
    /**
    * 教师工号
    */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @NotEmpty(message = "密码不允许为空")
    private String password ;
    /**
    * 教师姓名
    */
    @NotEmpty(message = "教师型名不允许为空")
    private String name;

    /**
    * 性别
    */
    @NotEmpty(message = "性别不允许为空")
    private String sex;

    /**
    * 邮箱
    */
    @NotEmpty(message = "邮箱不允许为空")
    private String email;

    /**
    * 电话号码
    */
    @NotEmpty(message = "电话不允许为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "电话号码格式不正确")
    private String phone;

    /**
    * 教授课程号
    */
    private Integer courseId;

    /**
     * 课程名
     */
    private String courseName ;

    @Override
    public Long getUsername() {
        return this.id;
    }

    @Override
    public String getRole() {
        return "teacher";
    }
}